<!doctype html>
<button id="sub">SUB</button>
<button id="wait">WAIT</button>
<textarea id="content" >

</textarea>
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.jsonp.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-notify.min.js"></script>
<script src="js/encoding-indexes.js"></script>
<script src="js/encoding.js"></script>
<script>

var token = 'eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNpMjN0KAiEQRt9lrhWcdNXZV4kl_JkFo7ZlVQiid8_opsvzncP3gtojzBDyvWwgoFc-LiWPxQ1KB4fGg3Ay6uQIPTqFAmp67AzzeRHAz_2ntXLkhyuh_fej2EK8fU_a0VnAtZXxTo599EpLj5qkyWxk1IgyGTu51VuytML7AwAA__8.E5e5IiQtCTZW-svMrno3dqHhXmqLv1FAbzUxicUOYZs';
var socket = io('http://localhost:9092?type=browser&token=' + token);
var deviceId = '4205dccb';
socket.on('connect', function(){});
socket.on('logcat', function(message){
    var content = $("#content").val()
    var j = JSON.parse(message)
    content = content + j.level
    $("#content").val(content);
    // console.log(message)
});
socket.on('disconnect', function(){});

$("#sub").click(function () {
    var filter_params = {
        deviceId: deviceId,
        filter: {
            tag: "",
            pid: "",
            level: "W",
            message: ""
        }
    }
    subLogcat(filter_params);
});

$("#wait").click(function () {
    waitLogcat();
});

function subLogcat(filter_params) {
    console.log("subLogcat")
    socket.emit("sub_logcat", JSON.stringify(filter_params))
}

function waitLogcat() {
    console.log("wait")
    socket.emit("wait_logcat", deviceId)
}
</script>
